** All options are on the table? Manuscript**
** Rotem Dvir **
** December 2020 **


***	Data SetUp	***
cd "C:\Users\r.dv-2014_app\Downloads"
log using FPA_main

clear all
set linesize 80
import delimited "/ChoiceSetData_June2019.csv"

***	Data prep	*********************
/// Download and install the packages tukeyhsd and qsturng to run the code

///	Create dependent variable: total options in choice-set
///	Since each policy is mesaured with a binary indicator, I add all 7 policy options
///	and create a variable for the total number of policies in a respondent's choice-set.
 
gen set_all=p1+p2+p3+p4+p5+p6+p7

/// Create variables for treatments in reduced sample (no control conditions)
gen cas=.
replace cas=0 if casualties==1
replace cas=1 if casualties==2

gen oth=.
replace oth=0 if other==1
replace oth=1 if other==2

********************************
*********	Models	************
********************************

*** Analysis 1: ANOVA models for choice-set size

/// Model 1: ANOVA, only treatments
anova set_all horizon casualties other

/// Contrasts: compute means per conditions and tests differences
tukeyhsd horizon
pwmean set_all, over(horizon) mcompare(tukey) effects

tukeyhsd other
pwmean set_all, over(other) mcompare(tukey) effects

tukeyhsd casualties
pwmean set_all, over(casualties) mcompare(tukey) effects

/// Model 2: ANOVA, full model
anova set_all horizon casualties other gender age party fp_know edu_cat 

/// Contrasts: compute means per conditions and tests differences
tukeyhsd horizon
tukeyhsd other
tukeyhsd casualties

/// Create age group variables based on sample distribution
/// Then, compute mean size of choice-set by group
sum age, detail

gen age_cat=.
replace age_cat=1 if age<30
replace age_cat=2 if age>29 & age<46
replace age_cat=3 if age>45 & age<57
replace age_cat=4 if age>56

/// Mean choice-set size for different age groups (ANOVA model 2)
tabstat set_all, by(age_cat) statistics(mean sd semean)

/// Create varibles for control conditions only (reduced sample analysis)
gen horz=.
replace horz=horizon if casualties==0

/// Create varible for control conditions and choice-set size 
gen horz2=horz if set_all>1

/// Run univariate OLS regression model with reduced sample
/// Compute mean values for both conditions using marginal effects (fit to figure 4 in main text)
/// Model results are diplayed in appendix file (table 3, model 3)
reg set_all horz2 gender party age fp_know edu_cat 
margins, at(horz2=(0 1))

*** Analysis 2: choice-set composition with probit interaction models

/// Probit interaction models (reduced sample, no control conditions)
///	Compute marginal effects for all conditions
/// Results of these models are displayed in appendix file (table 3, models 1&2)
probit p1 i.horizon i.oth i.cas i.horizon##i.oth gender age party fp_know edu_cat
margins, at(oth=(0 1) horizon=(0 1))


probit p2 i.horizon i.oth i.cas i.horizon##i.oth gender age party fp_know edu_cat
margins, at(oth=(0 1) horizon=(0 1))

*** Analysis 3: policy selection (phase 2 of experiment)

/// Selected policy: Multinomial regression model
/// Model results are displayed in main text (table 1: include only models 2-4)
mlogit pol_select horizon other casualties set_all ///
gender age party fp_know edu_cat, b(1)
margins, at(other=(1 2) horizon=(0 1)) predict(outcome(2))

*** Analysis 4: policy selection/preference reversal (phase 2 of experiment)
*** The role of the choice-set size

/// Create binary indicator for seleting policy 1
gen p1_sel=0
replace p1_sel=1 if pol_select==1
tab p1_sel

/// Probit regression model: also account for choice set size
///	Compute marginal effect of choice-set size 
probit p1_sel horizon other casualties set_all gender age party fp_know edu_cat
margins, at(set_all=(1(1)7)) 

/// Plot marginal effect of set size on probability of seleting policy 1
/// Figure 6 in main text
marginsplot, recast(line) ciopts(recast(rline) lp(dash) color(gs9)) ///
xtitle("Choice-Set Size") ytitle("Pr(Select PolicyOne)") title("") graphregion(color(white))

log close










